package com.example.gesturedemo;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;

public class PageView extends ViewPager {

    private State mState;
    private int oldPage;

    private View mLeft;
    private View mRight;
    private float mRot;
    private float mTrans;
    private float mScale;

    private enum State {
        IDLE, GOING_LEFT, GOING_RIGHT
    }

    public PageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private static int blendColors(int color1, int color2, float ratio) {
        final float inverseRation = 1f - ratio;
        float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
        float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
        float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
        return Color.rgb((int) r, (int) g, (int) b);
    }

    @Override
    protected void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        oldPage = getCurrentItem();
        mState = position == oldPage ? State.GOING_RIGHT : State.GOING_LEFT;
        super.onPageScrolled(position, positionOffset, positionOffsetPixels);
    }

}
